package com.ruoyi.livedemo.mapper;

import com.ruoyi.livedemo.entity.Attachment;
import org.apache.ibatis.annotations.*;

@Mapper
public interface AttachmentMapper {

    @Insert("INSERT INTO attachments (user_id, file_path, media_type, size_bytes, description) VALUES (#{userId}, #{filePath}, #{mediaType}, #{sizeBytes}, #{description})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Attachment attachment);

    @Select("SELECT * FROM attachments WHERE id=#{id} AND user_id=#{userId}")
    Attachment findByIdAndUser(@Param("id") Long id, @Param("userId") Long userId);

    @Delete("DELETE FROM attachments WHERE id=#{id} AND user_id=#{userId}")
    int delete(@Param("id") Long id, @Param("userId") Long userId);
}


